<style>
	#param-tb {
	    border: 1px solid #C5D7ED;
	    border-collapse: collapse;
	    color: #333333;
	    margin: 0 -1px;
	}
	#param-tb th, #param-tb td {
	    border: 1px solid #C5D7ED;
	    line-height: 28px;
	    padding: 0 15px;
	}
	#param-tb .val{
		width:390px;
	}
	#param-tb .val span {
	    display: block;
	    line-height: 28px;
	}
</style>
<script>


</script>

<h2 class="Content-title"><?php echo $Trade['Trade']['name']; ?></h2>
	    <div class="Content-info">
	   {{lang('view_nums')}}： 
	   <span class="ui-stats-num" id="Stats-Trade-{{$Trade['Trade']['id']}}-view_nums"><?php echo $Trade['Trade']['view_nums']; ?></span>
	    </div>
	    <div  id="Tradeinfo"  class="clearfix">		   
		    <ul style="float:left;margin-left: 10px;display: inline;">
	            <li>{{lang('price')}}: ${{$Trade['Trade']['price']}}  &nbsp;&nbsp;&nbsp;
	            	{{if $Trade['Trade']['status']==1}}
	            		<a aria-disabled="false" class="btn btn-primary" href="/trades/choose/{{$Trade['Trade']['id']}}">{{lang('barter')}} </a>
	            	{{elseif $Trade['Trade']['status']==2}}
	            		<a disabled="disabled" class="btn btn-primary" href="javascript:void(0)">{{lang('is bartering')}} </a>

	            		{{if $CurrentUser['id']==$Trade['Trade']['creator']}}
				    		<a class="btn btn-success" href="/trades/end_barter/{{$Trade['Trade']['id']}}/{{$choose_barter_id}}"> Barter Success.</a>

				    		<a class="btn btn-warning" href="/trades/rechoose/{{$Trade['Trade']['id']}}/{{$choose_barter_id}}"> Re-choose Barter offer.</a>
				    	{{/if}}
	            	{{/if}}
				</li>
	        </ul>
	    </div>
	    {{if $barters}}
	    <hr/>
	    <div class="panel panel-default">
		  <div class="panel-heading">
		    <h3 class="panel-title">User Match Offer</h3>
		  </div>
		  <div class="panel-body">
		    	<div class="row">
			    	<?php
			    		foreach($barters as $barter){
			    			$ids = explode(',',$barter['Barter']['barters']);

			    			echo '<ul class="col-md-6 list-group">';
			    			if($barter['Barter']['status']==2){
			    				echo '<a href="javascript:void(0)" style="background-color: #f2dede;" class="list-group-item">'.$barter['User']['username'].' <i class="glyphicon glyphicon-ok"></i>(matched)</a>';
			    			}
			    			else{
			    				echo '<a href="javascript:void(0)" class="list-group-item active">'.$barter['User']['username'].'</a>';
			    			}
			    			
			    			if($barter['Barter']['price']){
			    				echo '<li class="list-group-item"><a href="javascript:void(0)"> Money $'.$barter['Barter']['price'].'</a></li>';
			    			}
			    			foreach($ids as $id){
			    				echo '<li class="list-group-item"><a class="popover-trigger" data-container="body" data-toggle="popover" data-placement="right" data-title="'.$match_trades[$id]['name'].'" data-content="'.usubstr(strip_tags($match_trades[$id]['content']),0,300).'" href="javascript:void(0)">'.$match_trades[$id]['name'].' $'.$match_trades[$id]['price'].'</a></li>';
			    			}
			    			if($CurrentUser['id']==$Trade['Trade']['creator']){
			    				echo '<li class="list-group-item"><a onclick="return confirm(\'are you sure to match this?\')"  class="text-danger" href="/trades/start_barter/'.$Trade['Trade']['id'].'/'.$barter['Barter']['id'].'">Choose This To Start Barter.</a></li>';
			    			}
			    			echo '</ul>';
			    		}
			    	?>
			    </div>
		  </div>
		</div>
		{{/if}}
	    

<div style="clear:both;"></div>
<hr/>
<div class="tabs">
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#Trade-description">{{lang('description')}}</a></li>
</ul>
	<div id="Trade-description">
		    <div class="Content-body">
	        <div class="clear"></div>
		    <?php echo $Trade['Trade']['content']; ?>
		    	{{loop $upload_files $uploadfile}}
					 <img alt="{{$Trade['Trade']['name']}}" src="{{$this->Html->url($uploadfile['fspath'])}}">
				{{/loop}} 
		    </div>
	</div>
</div>

<script>
$(function(){
	
});
</script>


